package grid_operation;

import org.gdal.ogr.DataSource;
import org.gdal.ogr.Driver;
import org.gdal.ogr.Layer;
import utils.SelectFile;

public class ShapeFilter {
    public static void main(String[] a) {
        long time0 = System.currentTimeMillis();
        Driver driver = SelectFile.driverInit();

        String path = "D:\\TestDta\\新疆林业数据\\XZ1.shp";
        DataSource dataSource = driver.Open(path);

        Layer layer = dataSource.GetLayer(0);

        System.out.println("过滤前:" + layer.GetFeatureCount());
        layer.SetAttributeFilter(
                "DI_LEI='0111'");


        long time1 = System.currentTimeMillis();
        System.out.println("执行时间：" + (time1 - time0));
        System.out.println("过滤后:" + layer.GetFeatureCount());
        long time2 = System.currentTimeMillis();
        System.out.println("拿到过滤后数量时间：" + (time2 - time1));
    }
}
